<template>
  <nav>
    <div
      class="item"
      @click="changeActive(0)"
      :class="{ active: active === 0 }"
    >
      主页
    </div>
    <div
      class="item"
      @click="changeActive(1)"
      :class="{ active: active === 1 }"
    >
      歌曲
    </div>
    <div
      class="item"
      @click="changeActive(2)"
      :class="{ active: active === 2 }"
    >
      专辑
    </div>
    <div
      class="item"
      @click="changeActive(3)"
      :class="{ active: active === 3 }"
    >
      视频
    </div>
  </nav>
</template>

<script>
export default {
  methods: {
    // 激活变化
    changeActive(active) {
      this.active = active;
      this.$emit("changeActive", active);
    },
  },
  data() {
    return {
      active: 1,
    };
  },
  name: "SingerDetailNavBar",
};
</script>

<style lang="less" scoped>
nav {
  width: 100%;
  height: 30px;
  background-color: #fff;
  display: flex;
  justify-content: space-around;
  margin: 20px 0;
  position: sticky;
  top: 50px;
  z-index: 2;

  .item {
    width: 70px;
    height: 100%;
    line-height: 30px;
    font-weight: bolder;
    text-align: center;
    font-size: 14px;
    border-radius: 12px;

    &.active {
      color: #fff;
      background-color: #0ca1ff;
      transition: 0.5s;
    }
  }
}
</style>
